/**
 * @internal
 */
export class Tree<T> {
    readonly stack: Array<T>;

    constructor() {
        this.stack = [];
    }

    public push(element: T): void {
        this.stack.push(element);
    }

    public pop() {
        return this.stack.pop();
    }

    public top() {
        if (this.stack.length > 0) {
            return this.stack[0];
        }
        return undefined;
    }
}